package com.wfit.admin.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wfit.admin.service.IDictService;
import com.wfit.admin.entity.Dict;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 马真志
 * @since 2023-12-14
 */
@RestController
@RequestMapping("/dict")
    public class DictController {

@Resource
private IDictService dictService;

@PostMapping
public Boolean save(@RequestBody Dict dict) {
        return dictService.saveOrUpdate(dict);
        }

@DeleteMapping("/{id}")
public Boolean delete(@PathVariable Integer id) {
        return dictService.removeById(id);
        }

@GetMapping
public List<Dict> findAll() {
        return dictService.list();
        }

@GetMapping("/{id}")
public Dict findOne(@PathVariable Integer id) {
        return dictService.getById(id);
        }

@GetMapping("/page")
public Page<Dict> findPage(@RequestParam Integer pageNum,
@RequestParam Integer pageSize) {

        QueryWrapper<Dict> queryWrapper = new QueryWrapper<>();
        return dictService.page(new Page<>(pageNum, pageSize),queryWrapper);
        }

        }

